package drinkreos.model;

import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;

import com.thoughtworks.xstream.XStream;


public class Database {
	private static ArrayList<Card> cards;

	public static void download() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
		cards=new ArrayList<Card>();
		XStream xstream=new XStream();
			xstream.processAnnotations(Card.class);
		
		File cardFolder=new File("cards/");
		for(File f:cardFolder.listFiles()) {
			if(f.isFile() && f.getAbsolutePath().endsWith(".xml")) {
				Card c=(Card)xstream.fromXML(f);
				cards.add(c);
			}
		}
	}
	
	public static Collection<Card> getCards() {
		Collections.shuffle(cards);
		return cards;
	}
}
